<template>
  <div>
  <div>
    <i class="el-icon-discount" style="color: red;font-size: 20px"></i>
    <span style="font-size: 20px"><b>视频管理</b></span></div><br>
    <el-button type="primary">查找全部</el-button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <el-input v-model="input" placeholder="请输入名称" style="width: 250px"></el-input>
    <el-button type="primary">查找</el-button>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <el-input v-model="input" placeholder="请输入作者" style="width: 250px"></el-input>
    <el-button type="primary">查找</el-button>
    <el-button type="primary" style="float: right" @click="dialogFormVisible1=true">添加</el-button>
    <el-dialog title="添加饮食" :visible.sync="dialogFormVisible1"  width="40%" >
    </el-dialog>
    <el-divider></el-divider>

    <el-table
      :data="tableData"
      border
      style="width: 100%">
      <el-table-column
        prop="number"
        label="序号"
        width="100">
      </el-table-column>
      <el-table-column
        prop="videotitle"
        label="标题"
        width="260">
      </el-table-column>
      <el-table-column
        prop="brief"
        label="简介"
        width="500">
      </el-table-column>
      <el-table-column
        prop="createtime"
        label="上传时间"
        width="200">
      </el-table-column>
      <el-table-column
        label="审核状态"
        width="110">
        <template  slot-scope="scope">
        <el-button size="mini" :type=scope.row.color >{{scope.row.audit}}</el-button>
        </template>
      </el-table-column>
      <el-table-column
        label="审核">
        <template  slot-scope="scope">
          <router-link :to="{path:'/revisevideo',query:{videoid:scope.row.id}}" style="text-decoration: none;" >
            <el-button size="mini" @click="dialogFormVisible2=true">点击审核</el-button>
          </router-link>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>


<script>

export default {
  name: "details",
  data() {
    return {
      input:"",
      dialogFormVisible1: false,
      dialogFormVisible2: false,
      foodtype:"",
      tableData: [],
    }
  },
  methods:{
    // del(id){
    //   var foodid=id;
    //   console.log(foodid);
    //  var url="/food/delete/"+foodid;
    //   this.$axios.put(url)
    //     .then( (res)=> {
    //       if (res.data.code === 0) {
    //         this.$message({message:"删除成功！", type: 'success'})
    //         function myMessage() {
    //           location.reload(true);
    //         }
    //         setTimeout(myMessage, 500);
    //       }
    //       else {
    //         this.$message({message:"删除失败！", type: 'error'})
    //       }
    //     }).catch(function (error) {
    //     console.log(error);
    //   } );
    //
     },
  created() {
    var url = '/video/selectall';
    this.$axios.get(url)
      .then( (res)=> {
        console.log(res.data);
        this.tableData=[];
        for (var i = 0; i < res.data.data.length; i++) {
          let row = {} // 定义一个当前添加数据的行
          row.number=i+1;
          row.brief=res.data.data[i].brief;
          row.createtime=res.data.data[i].createtime;
          row.id=res.data.data[i].id;
          row.videotitle=res.data.data[i].videotitle;
          if(res.data.data[i].audit===0){
            row.audit="等待审核";
            row.color='warning';
          }
          else if (res.data.data[i].audit===1){
            row.audit="审核通过";
            row.color='success';
          }
          else {
            row.audit="审核拒绝";
            row.color='danger';
          }
          this.tableData.push(row);
        }
      }).catch(function (error) {
      console.log(error);
    } );
  },
}
</script>

<style scoped>

</style>
